package com.itheima.controller;

import com.itheima.pojo.entity.Address;
import com.itheima.pojo.entity.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wuJiaWei
 * @version 1.0
 */
@RestController
public class ResponseController {

    //字符串
    @RequestMapping(value ="hello")
    public Result hello(){
        return Result.success("hello");
    }
    //对象
    @RequestMapping(value ="getAddr")
    public Result getAddr(){
        Address address = new Address();
        address.setProvince("广东省");
        address.setCity("深圳市");
//        return address;
        return Result.success(address);
    }
    //集合
    @RequestMapping(value ="listAddr")
    public Result listAddr(){

        List<Address> list = new ArrayList<>();

        Address address = new Address();
        address.setProvince("广东省");
        address.setCity("深圳市");

        Address address2 = new Address();
        address2.setProvince("广东省");
        address2.setCity("广州市");

        list.add(address);
        list.add(address2);
        return Result.success(list);
    }
}
